
<div class="SipeiMain_r fr">

    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <?php
        $form = $this->beginWidget('CActiveForm', array(
            'action' => Yii::app()->createUrl($this->route),
            'method' => 'GET',
            'id' => 'searchForm'));
        ?>
        <table>
            <tbody>
                <tr>
                    <td width="87" align="right" class="pt10 pr2">考试项目：</td>
                    <td width="250" class="pt10">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select class="fl fontc_666" name="exam_id">
                                    <option value='0'>请选择</option>
                                    <?php if (!empty($info['exam'])): ?>
                                        <?php foreach ($info['exam'] as $gv): ?>
                                            <option value="<?php echo $gv['exam_id'] ?>" <?php if ($search['exam_id'] == $gv['exam_id']) echo 'selected'; ?> ><?php echo $gv['exam_term_name']; ?></option>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                                </select>
                            </span>
                        </span>
                    </td>
                    <td width="67" align="right" class="pt10 pr2">所属科目：</td>
                    <td width="250" class="pt10">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">

                                <select class="fl fontc_666" name="subject_id">
                                    <option value='0'>请选择</option>
                                    <?php if (!empty($info['subject'])): ?>
                                        <?php foreach ($info['subject'] as $gv): ?>
                                            <option value="<?php echo $gv['subject_id'] ?>" <?php if ($search['subject_id'] == $gv['subject_id']) echo 'selected'; ?> > <?php echo $gv['subject_name'] ?></option>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                                </select>

                            </span>
                        </span>
                    </td>
                    <td width="110" align="right" class="pt10"><input type="submit" value="查询" class="cursor b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12" /></td>
                </tr>

            </tbody>
        </table>
        <?php
        $this->endWidget();
        ?>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" onclick="add()" style="margin-right:30px;" class="cursor fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 ml20 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="63" align="center" class="m_hr_t m_hr_b pl10"><input type="checkbox" class="checkboxs"></th>
                        <th width="180" align="center" class="m_hr_t m_hr_b pl10">考试项目</th>
                        <th width="120" align="center" class="m_hr_t m_hr_b">科目</th>
                        <th width="180" align="center" class="m_hr_t m_hr_b">等级</th>
                        <th width="120" align="center" class="m_hr_t m_hr_b">分数下线</th>
                        <th width="120" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="center" class="m_hr_b pl10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['id'];?>" class="checkbox"></td>
                                <td align="center" class="m_hr_b fontc_666 pl10"><?php echo $value['exam_data']['exam_term_name']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['subject_data']['subject_name']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['grading_data']['grading_name']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['score']; ?></td>
                                <td align="center" class="m_hr_b">
                                    <img src="/themes/default/images/Sipei/edit.png" class="mr10 cursor" onclick="update(<?php echo $value['id']; ?>)" title="编辑"/>
                                    <img src="/themes/default/images/Sipei/delate.png" class="cursor" onclick="set_ok(<?php echo $value['id']; ?>)" title="删除"/>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="6" class="m_hr_b"><h1 align="center">暂无数据</h1></td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>

</div>


<script>
            function set_ok(id) {
                $.dialog.confirm('确定删除吗', function() {
                    
                    $.get('/grading/default/delete_all', {id: id}, function(data) {
            			if(data == 1){
							location.reload();
                		}else{
	               			 $.dialog.alert("删除失败");
	    					 return false;
                    	}
                });
            });
            }
            function delete_all(){
            	var aa='';
            		$("input[name='deleteAll[]']:checkbox:checked").each(function(){
						aa+=$(this).val()+',';
					});
					if(aa == ''){
						$.dialog.alert("请选择要删除条目");
						return false;
					}
					$.dialog.confirm('确定删除所选数据吗', function() {
            		aa+=0;
            	
            		$.get('/grading/default/delete_all', {id: aa}, function(data) {
            			if(data == 1){
							location.reload();
                		}else{
	               			 $.dialog.alert("删除失败");
	    					 return false;
                    	}
            		   
            	});
            });
		 }
            function add() {
                api = $.dialog({
                    id: 'testID2',
                    lock: true,
                    padding: 0,
                    fixed: true,
                    title: "新增",
                    width: 480,
                    height: 350,
                    max: false,
                    min: false
                });
                $.get('/grading/default/add', function(html) {
                    api.content(html);
                });
            }

            function update(id) {

                api = $.dialog({
                    id: 'testID2',
                    lock: true,
                    padding: 0,
                    fixed: true,
                    title: "编辑",
                    width: 480,
                    height: 350,
                    max: false,
                    min: false
                });
                $.get('/grading/default/update', {id: id,time:new Date()}, function(html) {
                    api.content(html);
                });
            }
	$(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");
                        if (checkedS) {
                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })
</script>
